﻿//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//    Crolengi, this program (a part of program) is gameengine based on C++\Directx
//    Copyright (C) 2008 Pashinin Anton Alekseevich (Crol)
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
//    (INCLUDING NEGLIGENCE OR OTHERWISE) 
//    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
//    EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//    Contacts: 
//    Mail: crolengi@gmail.com
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//#pragma warning( disable : 4996 )

#ifndef  Object_Manager_h
#define  Object_Manager_h


#include "..\\import\\CRLEngi_strings_lib\\CRLEngi_strings.h"
#include "..\\import\\param_trees_lib\\param_trees.h"

#include "include\\Objects\\object_super_class.h"

#include "include\\xAnimation\\Animated_CObject.h"

#include "include\\Objects\\Static_CObject.h"
#include "include\\Objects\\Static_CObject_VSM.h"

#include "include\\Objects\\CObject_PhysX.h"
#include "include\\Objects\\CObject_PhysX_VSM.h"

#include "include\\Utils\\Console.h"
#include "include\\Utils\\list.h"

#include "include\\Managers\\Effect_Manager.h"
#include "include\\Managers\\Light_Manager.h"
//#include "include\\Managers\\Resource_Maneger.h"
#include "include\\Managers\\Camera_Manager.h"

#include "include\\CC\\Graphic_CC.h"

#include "include\\Managers\\manager.h"

#include "include\\UI\\GInterface.h"

#include "include\\physx\UpdateTime.h"
//#################################################################################################################
///// 
/////              :: КЛАСС МЕНЕДЖЕРА ОБЪЕКТОВ ::
///// 
//#################################################################################################################
class CLREngi_Object_Manager:public manager{

protected:

public:
	unsigned int            LOADED_objects;        // число объектов
	unsigned int            LOADED_SIMPLE_objects; // число объектов Static_CObject

	unsigned int            ErrorsCount;

	CLREngi_Console        *Console;
	CLREngi_Effect_Manager *Effect_Manager;
	CLREngi_Light_Manager  *Light_Manager;
	CLREngi_PhysX          *phys_manager;
	CLREngi_Camera_Manager *Camera_Manager;

	//list      ObjectList; (virtual)
	list        ScriptedObjects;
	list        PhysXObjects;
	list        ScriptedPhysXObjects;

	list        AnimatedObjects;

	CLREngi_UI_GInterface  *GInterface;

	Graphic_CC    *Mario;

	CRLEngi_string  C1,C2,C3,Cmd; 

	unsigned int PhysX_lasttime;
	char  c[1024],EndEvent[1024];

//#################################################################################################################
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////    Чтение параметров из структуры
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	bool LoadFromRow(char *file){
		ErrorsCount = 0;
		CRLEngi_string a;
		a = file;
		DynamicRow row;
		row.iLoadFromFile(a);
		//a = "[i] Loading objects from ";
		//a += file;
		//a += " ...";
		//Console->AddText(a,2); 
		LoadFromRow(&row);
		return true;	
	}
	bool LoadFromRow(DynamicRow *row){
		ErrorsCount = 0;
	 
	  // подготовка к анализу структуры
		int id1 = 0, count,id2 = 0,id3 = 0,objCount = 0;
		CRLEngi_string ObjName,
			           ObjPath,
			           ObjType;
		D3DXVECTOR3    Position = D3DXVECTOR3(0.0f,0.0f,0.0f);
		D3DXVECTOR3    Rotation = D3DXVECTOR3(0.0f,0.0f,0.0f);

		ObjName = "";
		ObjPath = "";
		ObjType = "_OBJECT_SIMPLE_";

		id1 = (*row).iLookId("_OBJECTS_");
        count =  (*row).iCountKnots(id1) + (*row).iCountParams(id1);
		if (id1>0)
			if (count>0){//if0
              //// верхний элемент
			   id2      = (*row).TopId(id1);
			   ObjName  = (*row).iLookName(id2);
			   objCount = (*row).iCountKnots(id2) + (*row).iCountParams(id2);
			   int ii = (*row).iLookInFor(id2,"_OBJECT_TYPE_");
			       ii = (*row).TopId(ii);
			   ObjType =  (*row).iLookName(ii);
			       ii = (*row).iLookInFor(id2,"_OBJECT_PATH_");
				   ii = (*row).TopId(ii);
			   ObjPath =  (*row).iLookName(ii);

				   ii = (*row).iLookInFor(id2,"_POSITION_");
				   ii = (*row).TopId(ii);
			   Position.x=  ((*row).iLookName(ii)).toFloat();
			       ii = (*row).NextId(ii);
			   Position.y =  ((*row).iLookName(ii)).toFloat();
			       ii = (*row).NextId(ii);
			   Position.z = ( (*row).iLookName(ii)).toFloat();

			       ii = (*row).iLookInFor(id2,"_ROTATION_");
				   ii = (*row).TopId(ii);
			   Rotation.x=  ((*row).iLookName(ii)).toFloat();
			       ii = (*row).NextId(ii);
			   Rotation.y =  ((*row).iLookName(ii)).toFloat();
			       ii = (*row).NextId(ii);
			   Rotation.z = ( (*row).iLookName(ii)).toFloat();
			   
			   if ((ObjType=="_OBJECT_SIMPLE_"))
						         AddObject_SIMPLE_new(ObjPath,Position,Rotation);
			    else
			   if ((ObjType=="_OBJECT_SIMPLE_VSM_"))
						         AddObject_SIMPLE_VSM(ObjPath,Position,Rotation);
			   else
			   if ((ObjType=="_OBJECT_PHYSX_VSM_"))
						         AddObject_PHYSX_VSM(ObjPath,Position,Rotation);
			   else
			         if ((ObjType=="_OBJECT_ANIMATED_"))
						         AddAnimated_CObject(ObjPath,Position,Rotation);

			   for (int i=1;i<count;i++){
				    ObjType = "_OBJECT_SIMPLE_";
					ObjName = "";
		            ObjPath = "";
				    //// остальные элементы
					id2      = (*row).NextId(id2);

					ObjName  = (*row).iLookName(id2);
					objCount = (*row).iCountKnots(id2) + (*row).iCountParams(id2);
					int ii = (*row).iLookInFor(id2,"_OBJECT_TYPE_");
					    ii = (*row).TopId(ii);
					ObjType =  (*row).iLookName(ii);
					    ii = (*row).iLookInFor(id2,"_OBJECT_PATH_");
					    ii = (*row).TopId(ii);
					 ObjPath =  (*row).iLookName(ii);

						ii = (*row).iLookInFor(id2,"_POSITION_");
						ii = (*row).TopId(ii);
					Position.x=  ((*row).iLookName(ii)).toFloat();
						ii = (*row).NextId(ii);
					Position.y =  ((*row).iLookName(ii)).toFloat();
						ii = (*row).NextId(ii);
					Position.z = ( (*row).iLookName(ii)).toFloat();

					    ii = (*row).iLookInFor(id2,"_ROTATION_");
						ii = (*row).TopId(ii);
					Rotation.x=  ((*row).iLookName(ii)).toFloat();
						ii = (*row).NextId(ii);
					Rotation.y =  ((*row).iLookName(ii)).toFloat();
						ii = (*row).NextId(ii);
					Rotation.z = ( (*row).iLookName(ii)).toFloat();

					 if ((ObjType=="_OBJECT_SIMPLE_"))
						         AddObject_SIMPLE_new(ObjPath,Position,Rotation);
					 else
					 if ((ObjType=="_OBJECT_SIMPLE_VSM_"))
						         AddObject_SIMPLE_VSM(ObjPath,Position,Rotation);
					 else
			         if ((ObjType=="_OBJECT_PHYSX_"))
						         AddObject_PHYSX(ObjPath,Position,Rotation);
					 else
			         if ((ObjType=="_OBJECT_PHYSX_VSM_"))
						         AddObject_PHYSX_VSM(ObjPath,Position,Rotation);
					 else
			         if ((ObjType=="_OBJECT_ANIMATED_"))
						         AddAnimated_CObject(ObjPath,Position,Rotation);

			     }//for
			   }//if0

		CRLEngi_string message;
		message = "[!] Object Manager setup completed with ";
		message += (int)ErrorsCount;
		message += " errors and ";
		message += (int)LOADED_objects;
		message += " objects.";
		
		Console->AddText(message,3); 

           return true;	
	}//bool
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////   
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Static_CObject*     AddObject_SIMPLE_new(CRLEngi_string filename,D3DXVECTOR3    Position,D3DXVECTOR3    Rotation){

	LOADED_objects             += 1;
    LOADED_SIMPLE_objects      += 1;

    Static_CObject *a= new Static_CObject(matWorld,
				                                  filename.getChars(),
				                                  d3dDevice,
				                                  Effect_Manager,
				                                  Light_Manager,
				                                  Console);//,&ResManager);

	
	a->Position = Position;
	a->Rotation = Rotation;
	if (a->InitParameters()){

	 CRLEngi_string mess;
	 mess = "[+] ";
	 mess = filename;
 	 Console->AddText(mess); 

     ObjectList.Add(a);

	 return a;	} 
	ErrorsCount++;
	return NULL;
}
Animated_CObject*   AddAnimated_CObject(CRLEngi_string filename,D3DXVECTOR3    Position,D3DXVECTOR3    Rotation){

	LOADED_objects             += 1;
    LOADED_SIMPLE_objects      += 1;

    Animated_CObject *a= new Animated_CObject(matWorld,
				                                  filename.getChars(),
				                                  d3dDevice,
				                                  Effect_Manager,
				                                  Light_Manager,
				                                  Console);//,&ResManager);

	
	a->Position = Position;
	a->Rotation = Rotation;
	if (a->InitParameters()){

	 CRLEngi_string mess;
	 mess = "[+] ";
	 mess = filename;
 	 Console->AddText(mess); 

     AnimatedObjects.Add(a);

	 return a;	} 
	ErrorsCount++;
	return NULL;
}

unsigned int        AddObject_SIMPLE_VSM(CRLEngi_string filename,D3DXVECTOR3    Position,D3DXVECTOR3    Rotation){

	LOADED_objects             += 1;
    LOADED_SIMPLE_objects      += 1;

    Static_CObject *a= new Static_CObject_VSM(matWorld,
				                                  filename.getChars(),
				                                  d3dDevice,
				                                  Effect_Manager,
				                                  Light_Manager,
				                                  Console);//,&ResManager);

	
	a->Position = Position;
	a->Rotation = Rotation;
	if (a->InitParameters()){

     ScriptedObjects.Add(a);

	 return(true);	} 
	ErrorsCount++;
	return false;
}

unsigned int        AddObject_PHYSX(CRLEngi_string filename,D3DXVECTOR3    Position,D3DXVECTOR3    Rotation){

	LOADED_objects             += 1;
    //LOADED_SIMPLE_objects      += 1;

    CObject_PhysX *a= new CObject_PhysX(matWorld,
				                                  filename.getChars(),
				                                  d3dDevice,
				                                  Effect_Manager,
				                                  Light_Manager,
				                                  Console);//,&ResManager);

	
	a->Position = Position;
	a->Rotation = Rotation;
	if (a->InitParameters()){
	a->InitPhysX(phys_manager);

     PhysXObjects.Add(a);

	 return(true);	}
	ErrorsCount++;
	return false;
}

unsigned int        AddObject_PHYSX_VSM(CRLEngi_string filename,D3DXVECTOR3    Position,D3DXVECTOR3    Rotation){

	LOADED_objects             += 1;
    //LOADED_SIMPLE_objects      += 1;

    CObject_PhysX_VSM *a= new CObject_PhysX_VSM(matWorld,
				                                  filename.getChars(),
				                                  d3dDevice,
				                                  Effect_Manager,
				                                  Light_Manager,
				                                  Console);//,&ResManager);

	
	a->Position = Position;
	a->Rotation = Rotation;
	if (a->InitParameters()){
	a->InitPhysX(phys_manager);

     ScriptedPhysXObjects.Add(a);

	 return(true);	} 
	ErrorsCount++;
	return false;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////   Функции отрисовки объектов из списков, что какая делает можно понять из названия
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Render_All(float FPSMSeconds){

		

		phys_manager->Simulate(FPSMSeconds);

		NxReal             maxTimestep;
		NxTimeStepMethod   method;
		NxU32              maxIter;
		NxU32              numSubSteps;
		phys_manager->g_pScene->getTiming(maxTimestep, maxIter, method, &numSubSteps);

		Mario->update(5);//(float)(5/FPSMSeconds));
		Mario->Render();
		Mario->CCMgr->updateControllers();
		Mario->update(5);//(float)(5/FPSMSeconds));
		Mario->CCMgr->updateControllers();

		for(list::Item* I=AnimatedObjects.GetItems(); I!=NULL; I=I->next)
         {
         Animated_CObject* obj =(Animated_CObject*)I->ptr;
         obj->Render();
         }

		for(list::Item* I=ObjectList.GetItems(); I!=NULL; I=I->next)
         {
         Static_CObject* obj =(Static_CObject*)I->ptr;
         obj->Render(1,true);
         }

		for(list::Item* I=ScriptedObjects.GetItems(); I!=NULL; I=I->next)
         {
         Static_CObject_VSM* obj =(Static_CObject_VSM*)I->ptr;
         obj->Render(1,true);
         }

		 for(list::Item* I=PhysXObjects.GetItems(); I!=NULL; I=I->next)
         {
         CObject_PhysX* obj =(CObject_PhysX*)I->ptr;
         obj->Render(1,true);
         }

		 for(list::Item* I=ScriptedPhysXObjects.GetItems(); I!=NULL; I=I->next)
         {
         CObject_PhysX_VSM* obj =(CObject_PhysX_VSM*)I->ptr;
         obj->Render(1,true);
         }

        phys_manager->SimulationEnd();


        GInterface->Render();
		
}
void Render_Static(float FPSMSeconds){

		for(list::Item* I=ObjectList.GetItems(); I!=NULL; I=I->next)
         {
         Static_CObject* obj =(Static_CObject*)I->ptr;
         obj->Render(1,true);
         }

		for(list::Item* I=ScriptedObjects.GetItems(); I!=NULL; I=I->next)
         {
         Static_CObject_VSM* obj =(Static_CObject_VSM*)I->ptr;
         obj->Render(1,true);
         }

}
void Render_Animated(float FPSMSeconds){
        for(list::Item* I=AnimatedObjects.GetItems(); I!=NULL; I=I->next)
         {
         Animated_CObject* obj =(Animated_CObject*)I->ptr;
         obj->Render();
         }
}
void Render_PhysX(float FPSMSeconds){
  NxReal deltaTime = UpdateTime();
	
	//if(deltaTime>0.0){

	// Update the time step
	    

		PhysX_lasttime = Console->GetCurrientTime_mseconds();

	    phys_manager->Simulate(1.0);

		NxReal             maxTimestep;
		NxTimeStepMethod   method;
		NxU32              maxIter;
		NxU32              numSubSteps;
		phys_manager->g_pScene->getTiming(maxTimestep, maxIter, method, &numSubSteps);

		//FPSMSeconds = float(6*FPSMSeconds);

		Mario->update(6);//(float)(5/FPSMSeconds));
		Mario->Render();
		Mario->CCMgr->updateControllers();
		Mario->update(6);//(float)(5/FPSMSeconds));
		Mario->CCMgr->updateControllers();


         for(list::Item* I=PhysXObjects.GetItems(); I!=NULL; I=I->next)
         {
         CObject_PhysX* obj =(CObject_PhysX*)I->ptr;
         obj->Render(1,true);
         }

		 for(list::Item* I=ScriptedPhysXObjects.GetItems(); I!=NULL; I=I->next)
         {
         CObject_PhysX_VSM* obj =(CObject_PhysX_VSM*)I->ptr;
         obj->Render(1,true);
         }

        phys_manager->SimulationEnd();

}
void Render_Interface(float FPSMSeconds){
   GInterface->Render();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////   
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	void InitScripts(){

		for(list::Item* I=ScriptedObjects.GetItems(); I!=NULL; I=I->next)
         {
         Static_CObject_VSM* obj =(Static_CObject_VSM*)I->ptr;
         obj->InitParameters3();
         }	

		for(list::Item* I=ScriptedPhysXObjects.GetItems(); I!=NULL; I=I->next)
         {
         CObject_PhysX_VSM* obj =(CObject_PhysX_VSM*)I->ptr;
         obj->InitParameters3();
         }	
	
	}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	void text_to_console(CRLEngi_string text,short a){
		Console->AddText(text,a); 	
	}
	void text_to_console(char *text,short a){
		Console->AddText(text,a); 	
	}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////   Анализ команд
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	void    AnalyzeCommand(char *a){
	
	Cmd = a;
    AnalyzeCommand(Cmd);
	}
	bool    AnalyzeCommand(CRLEngi_string  Command){

	  
	 // Command.NoTabs();
	  C1.clear();C2.clear();C3.clear();
	  //Command.DivideTwoParameters(&C1,&C2);	
	  
	  sscanf(Command.getChars(),"%s %1024[^'@']",c,EndEvent);
	  C1=c; C2=EndEvent;

	  C1.HideHoles();
	  //C2.HideHoles();
	  if (C1=="run"){
		 run_commands();	 
	  }else if (C1=="GInt"){
	    GInterface->AnalyzeCommand(C2);
	  }else{
		  
		for(list::Item* I=ScriptedObjects.GetItems(); I!=NULL; I=I->next)
         {
           Static_CObject_VSM* obj =(Static_CObject_VSM*)I->ptr;
		   C3 = obj->Name;
		   if(C1==C3) {
			   obj->AnalyzeCommand(C2);
			   return true;
		   }
         }
        
		for(list::Item* I=ScriptedPhysXObjects.GetItems(); I!=NULL; I=I->next)
         {
           CObject_PhysX_VSM* obj =(CObject_PhysX_VSM*)I->ptr;
		   C3 = obj->Name;
		   if(C1==C3) {
			   obj->AnalyzeCommand(C2);
			   return true;
		   }
         }
	  }
		return false;
	
	}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// обработка команд у скритповых объектов
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void    run_commands(){
      for(list::Item* I=ScriptedObjects.GetItems(); I!=NULL; I=I->next)
          {
               Static_CObject_VSM* obj =(Static_CObject_VSM*)I->ptr;
		   	   obj->run_commands();
          }

	  for(list::Item* I=ScriptedPhysXObjects.GetItems(); I!=NULL; I=I->next)
          {
              CObject_PhysX_VSM* obj =(CObject_PhysX_VSM*)I->ptr;
		   	   obj->run_commands();
          }

}
bool    Console_Input(CRLEngi_string  Command){
	    /// приходит ***manager self [command]    - команда адресованна менеджеру а не его элементам
		/// приходит ***manager [name] [command]  - команда адресованна его элементам
	    /// приходит ***manager [id] [command]  - команда адресованна его элементам
		CRLEngi_string  C1,C2;
	    Command.DivideTwoParameters(&C1,&C2);
		if (C1=="self"){ AnalyzeCommand(C2); return true;}

         for(list::Item* I=ObjectList.GetItems(); I!=NULL; I=I->next)
         {
           Static_CObject* obj =(Static_CObject*)I->ptr;
		    if (I->index == C1.toInt())
            obj->Console_Input(C2);
          // obj->Render(i,true);
         }

		 return true;


}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void    Init_CharacterController(){
	
	CRLEngi_string filename;
    filename = "objects\\CC.o";
	Mario = new Graphic_CC(phys_manager->ccMgr,phys_manager->g_pScene,d3dDevice,Camera_Manager);
	Static_CObject *obj= new Static_CObject(matWorld,
				                            filename.getChars(),
				                            d3dDevice,
				                            Effect_Manager,
				                            Light_Manager,
				                            Console);

	
	obj->Position = D3DXVECTOR3(0,0,0); obj->Rotation = D3DXVECTOR3(0,0,0);
	obj->InitParameters();

	Mario->Init(200,170,obj);
	Mario->SetPosition(2600,22000,0);
	float a[3]; a[1] = -2.5;a[2] = 0;a[3] = 0;
	Mario->SetVector(a);

	

}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void     Init_GlobalInterface(){

    GInterface->set_cam_mngr(Camera_Manager);
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void KeyBoardInput(float  Time){
    Mario->KeyboardInput(Time);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void SendMouseClickEvent(D3DXVECTOR3 *vPickRayDir,D3DXVECTOR3 *vPickRayOrig){

    for(list::Item* I=ScriptedObjects.GetItems(); I!=NULL; I=I->next)
         {
         Static_CObject_VSM* obj =(Static_CObject_VSM*)I->ptr;
         obj->MousePick(vPickRayDir,vPickRayOrig);
         }
    for(list::Item* I=ScriptedPhysXObjects.GetItems(); I!=NULL; I=I->next)
         {
         CObject_PhysX_VSM* obj =(CObject_PhysX_VSM*)I->ptr;
          obj->MousePick(vPickRayDir,vPickRayOrig);
         }
}
//#################################################################################################################
public:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////                                                                                                   КОНСТРУКТОР
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	CLREngi_Object_Manager(D3DXMATRIXA16* GMatrix,
		LPDIRECT3DDEVICE9   *Device,
		CLREngi_Effect_Manager *Eff_Manager,
		CLREngi_Light_Manager    *L_Manager,
		CLREngi_PhysX *phys_man,
		CLREngi_Camera_Manager* CamMngr,
		CLREngi_Console   *Cnsl){ 

		LOADED_objects        = 0;
		LOADED_SIMPLE_objects = 0;
//		head = NULL;
		matWorld = GMatrix;
		d3dDevice = Device;
		Effect_Manager = Eff_Manager;
		Light_Manager = L_Manager;
		phys_manager = phys_man;
		Console = Cnsl ;	

		 Camera_Manager = CamMngr;


        GInterface = new CLREngi_UI_GInterface(Device);

		PhysX_lasttime = Console->GetCurrientTime_mseconds();

	};

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////                                                                                                    ДЕСТРУКТОР
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	virtual ~CLREngi_Object_Manager(){
/*
	NODE_PTR curr;
	
	for (int i = 1; i<=Light_Manager->LOADED_lights;i++){
	 curr = head;
	 if(curr!=NULL)
	    while (true){
				
			        curr->Object->~Object_Super();

			if (curr->next==NULL)break;
			curr=curr->next;
		}
	}*/
		//for (int i =1;i<=LOADED_objects;i++)
		//	DestroyObject(i);

	};
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#endif 
